#include <string.h>
#include "k2l.h"

static k2l_sexp_ref ___cons(k2l_sexp_ref, k2l_sexp_ref*);
static k2l_sexp_ref ___stringeq(k2l_sexp_ref, k2l_sexp_ref*);

static k2l_function_t fnctab[] = {
	DECLARE_FUNCTION(___cons),
	DECLARE_FUNCTION(___stringeq),
#define FNCTAB_NUM (sizeof(fnctab)/sizeof(k2l_function_t))
};

static k2l_symbol_t symtab[] = {
	DECLARE_SYMBOL("NIL", DECLARE_REF(&symtab[0]), K2L_UNDEF),
	DECLARE_SYMBOL("T", DECLARE_REF(&symtab[1]), K2L_UNDEF),
	DECLARE_SYMBOL("BOOLEAN", K2L_UNDEF, K2L_UNDEF),
	DECLARE_SYMBOL("NULL", K2L_UNDEF, K2L_UNDEF),
	DECLARE_SYMBOL("SEQUENCE", K2L_UNDEF, K2L_UNDEF),
	DECLARE_SYMBOL("STRING", K2L_UNDEF, K2L_UNDEF),
	DECLARE_SYMBOL("SYMBOL", K2L_UNDEF, K2L_UNDEF),
	DECLARE_SYMBOL("CONS", K2L_UNDEF, DECLARE_REF(&fnctab[0])),
	DECLARE_SYMBOL("STRING=", K2L_UNDEF, DECLARE_REF(&fnctab[1])),
#define SYMTAB_NUM (sizeof(symtab)/sizeof(k2l_symbol_t))
};

const k2l_type_t k2l_ty_sequence = {NULL, {(k2l_sobj_t*)&symtab[4]}, NULL};
const k2l_type_t k2l_ty_string = {&k2l_ty_sequence, {(k2l_sobj_t*)&symtab[5]}, NULL};
const k2l_type_t k2l_ty_symbol = {NULL, {(k2l_sobj_t*)&symtab[6]}, NULL};
const k2l_type_t k2l_ty_cons = {&k2l_ty_sequence, {(k2l_sobj_t*)&symtab[7]}, NULL};

const k2l_sexp_ref g_k2l_t = {&(k2l_sobj_t){0, NULL}};
const k2l_sexp_ref g_k2l_nil = {NULL};

static k2l_sexp_ref ___type_of(k2l_sexp_ref args, k2l_sexp_ref *mvp)
{
	return SOBJ_TYPE(CONS_CAR(args))->specifier;
}

